﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Lesson11 : MonoBehaviour
{
    public Transform testObject;

    public Transform A;
    public Transform B;
    public Transform target;

    private Quaternion start;
    private float time;

    public Transform Player;
    public Transform Monster;
    // Start is called before the first frame update
    void Start()
    {
        #region 知识一 单位四元数
        print(Quaternion.identity);
        //testObject.rotation = Quaternion.identity;

        ////一般用于初始化旋转赋值
        //Instantiate(testObject, Vector3.zero, Quaternion.identity);
        #endregion

        #region 知识二 插值运算
        //start = B.rotation;
        #endregion
    }

    // Update is called once per frame
    void Update()
    {
        #region 知识二 插值运算
        //无限接近 先快后慢
        //A.transform.rotation = Quaternion.Slerp(A.transform.rotation, target.rotation, Time.deltaTime);

        //匀速变化 time>=1 到达目标
        //time += Time.deltaTime;
        //B.transform.rotation = Quaternion.Slerp(start, target.rotation, time);
        #endregion

        #region 知识三 LookRotation
        //怪物一直看向玩家
        Quaternion q = Quaternion.LookRotation(Player.position - Monster.position);
        Monster.rotation = q;
        #endregion
    }
}
